package com.example.sort;

import java.util.Arrays;

/**
 * @author zhanpengguo
 * @date 2019-07-30 16:44
 */
public class ChaRu {

    public static Integer[] sort(Integer[] arrays) {
        Integer[] ints = Arrays.copyOf(arrays, arrays.length);
        for (int i = 0; i < ints.length; i++) {
            int current = ints[i];
            int preIndex = i - 1;
            while (preIndex >= 0 && ints[preIndex] > current) {
                ints[preIndex + 1] = ints[preIndex];
                preIndex--;
            }
            ints[preIndex + 1] = current;
        }
        return ints;
    }
}
